﻿<div id="AjaxPaging">
    @using Webdiyer.WebControls.Mvc
    @model PagedList<NationalIT.split_expenses>
    <script type="text/javascript">
        $(document).ready(function () {
            ajaxPagingByID("AjaxPaging");
        });
    </script>
    <table class="table">
        <tr>
            <th>
                <input type="checkbox" name="" value="" class="checkAll" />
            </th>
            <th>
                ID
            </th>
            <th>
                Owner / Driver
            </th>
            <th>
                Expenses
            </th>
            <th>
                Amount
            </th>
            <th>
                Details
            </th>
            <th>
                Date
            </th>
            <th>
                Fee_Charged
            </th>
            <th>
                Current_Payroll
            </th>
            <th>
                Paid_Off
            </th>
        </tr>
        @if (Model.TotalItemCount > 0)
        {
            foreach (var item in Model)
            {
            <tr>
                <td>
                    <input type="checkbox" name="checkOwner" value="@item.Id" class="checkitem"/>
                </td>
                <td>
                    @Html.ActionLink(item.Id.ToString(), "NewOrEdit", new { id = item.Id })
                </td>
                <td>
                    @{
                if (item.OwnerDriver == 2)
                {
                    var driver = NationalIT.DB.Entities.Driver_Info.FirstOrDefault(m => m.ID == item.Idndex);
                    if (driver != null)
                    {
                        @driver.Last_name @driver.First_name <span class="colorBlue">(Driver)</span>
                    }
                }
                else
                {
                    var owner = NationalIT.DB.Entities.Owners.FirstOrDefault(m => m.OwnerID == item.Idndex);
                    if (owner != null)
                    {
                        @owner.Name <span class="f_req">(Owner)</span>
                    }
                }

                    }
                </td>
                <td>
                    @item.Expenses
                </td>
                <td>
                    @String.Format("{0:C}", item.Amount)
                </td>
                <td>
                    @item.Details
                </td>
                <td>
                    @(item.Date.HasValue ? item.Date.Value.ToString("MM/dd/yyyy") : "")
                </td>
                <td>
                    @NationalIT.CommonFunction.getYesNO(item.Fee_Charged)
                </td>
                <td>
                    @NationalIT.CommonFunction.getYesNO(item.Current_Payroll)
                </td>
                <td>
                    @NationalIT.CommonFunction.getYesNO(item.Paid_Off)
                </td>
            </tr>
            }
        }
    </table>
    <div class="row-fluid">
        <div class="span4">
            <div class="dataTables_info">
                @if (Model.TotalItemCount > 0)
                {
                    if (Model.TotalItemCount < Model.PageSize)
                    {
                    <span>1 </span>
                    <span>- </span>@Model.TotalItemCount
                    }
                    else
                    {
                    <span></span>@((Model.CurrentPageIndex - 1) * Model.PageSize + 1)
                    <span>- </span>@((Model.CurrentPageIndex != Model.TotalPageCount) ? (Model.CurrentPageIndex * Model.PageSize) : Math.Abs((Model.CurrentPageIndex) * Model.PageSize - (Model.PageSize * Model.TotalPageCount) - Model.TotalItemCount))
                    }
                    <span>of </span>@(Model.TotalItemCount)                            
                }
            </div>
        </div>
        <div class="span8">
            <div class="dataTables_paginate paging_bootstrap pagination phantrangmvcpager">
                @Html.AjaxPager(Model, new PagerOptions { ContainerTagName = "ul", PageIndexParameterName = "page", CurrentPagerItemWrapperFormatString = "<li class='active'>{0}</li>", CurrentPageNumberFormatString = "{0}", FirstPageText = "&laquo; ", LastPageText = " &raquo;", NextPageText = "Next →", PrevPageText = "← Prev", SeparatorHtml = "" }, new AjaxOptions { UpdateTargetId = "AjaxPaging" })
            </div>
        </div>
    </div>
</div>
